<template>
    <div>
      <div id="content">
        <van-nav-bar
          title="智能穿戴"
          :border="false"
          left-arrow
          @click-left="$router.push('/home')"
        />
        <div class="img">
          <img src="@/assets/sysimg/clothe.png" alt="" />
        </div>
  
        <div class="clothe">
          <span></span>
          <span>智能穿戴</span>
        </div>
  
        <div class="list">
          <router-link  
          :to="`/goods/${item.cid}`"
          v-for="(item, index) in clothes" :key="item.cid" 
             class="clo">
              <ClotheList :name="item.name" :price="item.price" :paynumer="item.paynumer" :imgname="clothesImg[index]"></ClotheList>
          </router-link>
        </div>
      </div>
    </div>
  </template>
  <script>
  import ClotheList from '@/components/clotheList'
  import { getClothe, getClotheImg } from '@/api/clothe'
  export default {
      data () {
          return {
              // 定义数组保存智能穿戴数据
              clothes: [],
              // 定义数组保存对应的图片
              clothesImg: []
          }
      },
      components: {
          ClotheList
      },
      methods: {
          // 获取智能穿戴信息
          async getWear () {
              const data = await getClothe()
              this.clothes = data.data.message
              console.log(this.clothes)
          },
          // 获取智能穿戴信息图片
          async getWearImg () {
              const data = await getClotheImg()
              console.log(data)
              data.data.message.forEach(item => {
                this.clothesImg.push(item.imgname)
              })
          }
      },
      mounted () {
          this.getWear()
          this.getWearImg ()
      }
  }
  </script>
  
  <style lang="scss" scoped>
  #content {
    .van-nav-bar {
      ::v-deep .van-icon {
        color: black;
      }
      ::v-deep .van-nav-bar__title {
        font-weight: bold;
        font-family: "黑体";
      }
    }
    > .img {
      width: 328px;
      height: 130px;
      margin: 0 auto;
      margin-top: 20px;
  
      img {
        width: 328px;
        height: 130px;
      }
    }
  
    .clothe {
      margin-top: 30px !important;
      width: 328px;
      margin: 0 auto;
  
      height: 22px;
      margin: 0 auto;
      line-height: 22%;
      font-family: "黑体";
  
      span:first-child {
        width: 2px;
        height: 12px;
        display: inline-block;
        background: #3ed3f7;
      }
      span:last-child {
        font-size: 18px;
        margin-left: 5px;
        color: #333333;
        // font-weight: bold;
      }
    }
  
    .list {
      width: 328px;
      margin: 0 auto;
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;
  
      .clo {
          color: black;
          margin-bottom: 13px;
      }
    }
  }
  </style>
  